export function parseDate(date = new Date()) {
  console.log(date.getFullYear())
  let year = date.getFullYear()
  let month = (date.getMonth() + 1 + "").padStart(2, "0")
  let day = ("" + date.getDate()).padStart(2, "0")

  return `${year}-${month}-${day}`
}
export function getNowDate() {
  let date = new Date()
  console.log(date.getFullYear())
  let year = date.getFullYear()
  let month = (date.getMonth() + 1 + "").padStart(2, "0")
  let day = ("" + date.getDate()).padStart(2, "0")

  return `${year} 年 ${month} 月 ${day} 日`
}

export const spec = [{
    label: '斤',
    value: '斤'
  },
  {
    label: '件',
    value: '件'
  }, {
    label: '袋',
    value: '袋'
  },
  {
    label: '箱',
    value: '箱'
  },
  {
    label: '盒',
    value: '盒'
  },
  {
    label: '瓶',
    value: '瓶'
  },
  {
    label: '条',
    value: '条'
  },
  {
    label: '包',
    value: '包'
  },
  {
    label: '个',
    value: '个'
  }
]

export const setText = {
  "0": '未结算',
  '1': '已结算',
  '2': '结算中'
};

/**
 * 将阿拉伯数字转换为大写中文数字
 * @param {number|string} num 需要转换的数字
 * @returns {arrray} 中文大写数字
 */
export function numberToChineseFull(num) {
  
  const chars = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
  if (typeof num === 'string') num = Number(num);
  if (typeof num !== 'number' || isNaN(num) || num < 0 || num > 99999999.99) return '';
  if (num === 0) return chars[0] + '元';
  // 处理小数部分
	let strRight = (num+"").split(".")[1] || ''
	let strLeft = (num+"").split(".")[0]
	
	strRight = strRight.padEnd(2,'0')
	strLeft = strLeft.padStart(7,"0")
	let arr = [...strLeft,...strRight]
	
	arr.forEach((item,index)=>{
		arr[index] = chars[item]
	})
	
	return arr
  // let str = (Math.round(num * 100)).toString(); // 以分为单位
  // let result = '';
  // for (let i = 0; i < str.length; i++) {
  //   let n = parseInt(str[str.length - 1 - i]);
  //   let unit = units[i] || '';
  //   if (n === 0) {
  //     if (!result.startsWith(chars[0]) && result.length > 0) {
  //       result = chars[0] + result;
  //     }
  //   } else {
  //     result = chars[n] + unit + result;
  //   }
  // }
  // // 去除多余的零
  // result = result.replace(/零+/g, '零');
  // // 去除"零元"前的零
  // result = result.replace(/^零+/, '');
  // // 处理"元"后面连续的零
  // result = result.replace(/元零+/, '元');
  // // 处理"角分"全为零的情况
  // result = result.replace(/元$/, '元整');
  // // 处理"零角零分"
  // result = result.replace(/零角零分$/, '整');
  // // 处理"零分"
  // result = result.replace(/零分$/, '整');
  // // 处理"零角"
  // result = result.replace(/零角/, '');
  // // 处理"零万"
  // result = result.replace(/零万/, '万');
  // // 处理"零元整"
  // result = result.replace(/^零元整$/, chars[0] + '元整');
  // return result;
}